package com.xiong.xtools.sectionrecyclerview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.xiong.xtools.R;
/**
 * Author : 熊文强
 * Time : 2017/10/11
 * Content : 实现分组列表RecyclerView
 */
public class SectionRecyclerActivity extends AppCompatActivity {
	private RecyclerView mRecyclerView;
	private HotelEntityAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_section_recycler);
		initView();
	}

	private void initView() {
		mRecyclerView = (RecyclerView) findViewById(R.id.sectionRecyclerView);
		mAdapter = new HotelEntityAdapter(this);
		// 设置列数
		GridLayoutManager manager = new GridLayoutManager(this,4);
		//设置header
		manager.setSpanSizeLookup(new SectionedSpanSizeLookup(mAdapter,manager));
		mRecyclerView.setLayoutManager(manager);
		mRecyclerView.setAdapter(mAdapter);
		// res-raw中的json.json文件
		HotelEntity entity = JsonUtils.analysisJsonFile(this,"json");
		mAdapter.setData(entity.allTagsList);
	}
}
